#pragma once

#include "material.h"
#include "vector3.h"

namespace raytrace {

struct Ray;

class Primitive {
 public:
  virtual ~Primitive() {
    delete material_;
  }

  void DumpToLog() const;

  virtual bool IntersectsWith(const Ray& r, float& d) const = 0;
  virtual Vector3 NormalAt(const Vector3& pt) const = 0;

  virtual Vector3 GetRandomPoint() const = 0;
  
  const Material* material() const { return material_; }

  virtual const char* type() const = 0;

  Vector3 pos_;
  uint32_t id_; // mostly for debugging

 protected:
  Primitive(const Vector3& pos, const Material* material)
    : pos_(pos),
      id_((uint32_t)-1),
      material_(material) { }

 private:
   const Material* material_;
};
}
